package com.s4j.core.manager.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name="S4J_SYSPROJECT")
public class SysProject {

	private Long projectId;
	
	/*
	 * 编号；非空；
	 */
	private String projectNo;
	
	/*
	 * 名字，非空
	 */
	private String projectName;
	
	/*
	 * 类型 非空
	 */
	private Short projectType;
	
	/*
	 * 排序号
	 */
	private Integer sortNum;
	
	/*
	 * 层级,非空
	 */
	private Short level;
	
	/*
	 * 是否叶子节点，非空
	 */
	private Short isLeaf;
	
	/*
	 * 图标
	 */
	private String icon;
	
	/*
	 * 父节点
	 */
	private SysProject parent;
	
	/*
	 * 子节点列表
	 */
	private List<SysProject> children;
	
	private SysModule module;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getProjectId() {
		return projectId;
	}

	public void setProjectId(Long projectId) {
		this.projectId = projectId;
	}
	
	@Column(length=50, nullable=false, unique=true)
	public String getProjectNo() {
		return projectNo;
	}

	public void setProjectNo(String projectNo) {
		this.projectNo = projectNo;
	}

	@Column(length=50, nullable=false, unique=true)
	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	@Column(precision=2, scale=0, nullable=false)
	public Short getProjectType() {
		return projectType;
	}

	public void setProjectType(Short projectType) {
		this.projectType = projectType;
	}

	@Column(precision=5, scale=0, nullable=false)
	public Integer getSortNum() {
		return sortNum;
	}

	public void setSortNum(Integer sortNum) {
		this.sortNum = sortNum;
	}

	@Column(precision=2, scale=0, nullable=false)
	public Short getLevel() {
		return level;
	}

	public void setLevel(Short level) {
		this.level = level;
	}

	@Column(precision=1, scale=0, nullable=false)
	public Short getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(Short isLeaf) {
		this.isLeaf = isLeaf;
	}

	@Column(length=100, nullable=true, unique=false)
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
	@JoinColumn(name="parentId")
	public SysProject getParent() {
		return parent;
	}

	public void setParent(SysProject parent) {
		this.parent = parent;
	}

	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="parent")
	public List<SysProject> getChildren() {
		return children;
	}

	public void setChildren(List<SysProject> children) {
		this.children = children;
	}

	@OneToOne(mappedBy="project",fetch=FetchType.EAGER)
	public SysModule getModule() {
		return module;
	}

	public void setModule(SysModule module) {
		this.module = module;
	}
}
